package com.example.mysecondapp;



import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.database.MatrixCursor;
import android.support.v4.widget.SimpleCursorAdapter;
import android.view.LayoutInflater;
import android.view.Menu;
import android.widget.LinearLayout;
import android.widget.ListView;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.activity_main);
		String[] col = new String[3];
		col[0]="_id";
		col[1]="col2";
		col[2]="col3";
		MatrixCursor cursor = new MatrixCursor(col);
		String[] val1 = new String[3];
		val1[0]="val11";
		val1[1]="val12";
		val1[2]="val13";
		String[] val2 = new String[3];
		val2[0]="val21";
		val2[1]="val22";
		val2[2]="val23";
		String[] val3 = new String[3];
		val3[0]="val31";
		val3[1]="val32";
		val3[2]="val33";	
		
		cursor.addRow(val1);
		cursor.addRow(val2);
		cursor.addRow(val3); 
		
		int[] toViews = { R.id.col1,R.id.col2};
		SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.linealvertical, cursor, col, toViews, 0);
		
        String infService = Context.LAYOUT_INFLATER_SERVICE;
    	LayoutInflater li;
    	li = (LayoutInflater) this.getSystemService(infService);
    	LinearLayout h= new LinearLayout(this);
    	li.inflate(R.layout.linearhor, h);
    	LinearLayout v= new LinearLayout(this);
    	li.inflate(R.layout.linealvertical, v);
    	
    	ListView lv = new ListView(this);
    	li.inflate(R.layout.listview, lv);
    	
    	v.addView(lv);
    	h.addView(v);
    	setContentView(h);
    	lv.setAdapter(adapter);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}
